<?php
namespace Goods;
class BuyController extends BaseController{
	function __construct(){
		parent::__construct();
		if (!$this->uid || !$this->username){
			$continue = urlencode(curPageURL());
			$this->redirect('/?m=member&c=login&continue='.$continue);
		}
	}
	
	public function index(){
		global $G,$lang;
		
		$id = intval($_GET['id']);
		$goods = goods_get_data(array('id'=>$id));
		if ($goods) {
			$image = image_get_data(array('dataid'=>$id,'datatype'=>'goods'));
			$goods['image'] = $image['image'];
			$goods['thumb'] = $image['thumb'];
			
			$addresslist = address_get_list(array('uid'=>$this->uid));
			$goods_number = intval($_GET['goods_number']);
			$goods_price  = $goods['isdiscount'] ? $goods['discount_price'] : $goods['price'];
			$total_amount = $goods_price * $goods_number;
			include template('buy');
		}else {
			$this->notFound();
		}
	}
}